#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>

#define NMAX 20

void fonct ( int s ) {

	static int intn=0,quitn=0;

	switch(s) {
		case SIGINT : intn++;printf("SIGINT RECU\n");break;
		case SIGQUIT : quitn++;printf("SIGQUIT RECU\n");break;
	}

	if( intn > NMAX || quitn > NMAX ) {
		printf("Nombre max reçu fin du processus\n");
		exit(0);
	}

}

int main ( int argc , char** argv ) {

	struct sigaction actionsig;
	
	actionsigint.sa_handler = fonct;
	actionsigint.sa_flags = 0;

	if(sigaction(SIGINT,&actionsig,NULL) == -1 ) {
		perror("Erreur affectation SIGINT : ");
		exit(-1);
	}

	if(sigaction(SIGQUIT,&actionsig,NULL) == -1 ) {
		perror("Erreur affectation SIGQUIT : ");
		exit(-1);
	}

	while(1);

	return 0;

}

